/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ontologia.session;

import com.ontologia.entities.Conceptos;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Sebastian Rojas
 */
@Stateless
public class ConceptosFacade extends AbstractFacade<Conceptos> {

  @PersistenceContext(unitName = "ontologia-ejbPU")
  private EntityManager em;

  @Override
  protected EntityManager getEntityManager() {
    return em;
  }

  public ConceptosFacade() {
    super(Conceptos.class);
  }

  public List<Conceptos> todosLosPaquetes() {
    List<Conceptos> listaConceptos;
    Query query = getEntityManager().createNamedQuery("Conceptos.findAll");
    listaConceptos = query.getResultList();
    return listaConceptos;
  }

  public Conceptos existeConcepto(String descripcion) {
    Conceptos concepto = null;
    Query query = getEntityManager().createNamedQuery("Conceptos.findByDescripcion");
    query.setParameter("descripcion", descripcion);
    concepto = (Conceptos) query.getSingleResult();
    return concepto;
  }

}
